import {
  dataList,
  reviewDelete,
  sensitiveList,
  sensitiveAdd,
  sensitiveDelete,
  sensitiveImport
} from '@/api/data'
import utils from '@/utils/common'
var timeStamp = Number(new Date())
const data = {
  state: {},

  mutations: {},

  actions: {
    // 数据列表统计
    DataList ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        keyword: data.keyword,
        appTypeId: data.appTypeId,
        page: data.page || '',
        pageSize: data.pageSize || ''
      }
      return new Promise((resolve, reject) => {
        dataList(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 评论删除
    ReviewDelete ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        id: data.id
      }
      return new Promise((resolve, reject) => {
        reviewDelete(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 敏感词列表
    SensitiveList ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        keyword: data.keyword,
        page: data.page || '',
        pageSize: data.pageSize || ''
      }
      return new Promise((resolve, reject) => {
        sensitiveList(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 敏感词添加
    SensitiveAdd ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        words: data.words
      }
      return new Promise((resolve, reject) => {
        sensitiveAdd(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 敏感词删除
    SensitiveDelete ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        id: data.id
      }
      return new Promise((resolve, reject) => {
        sensitiveDelete(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 敏感词导入
    SensitiveImport ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        fileUrl: data.fileUrl
      }
      return new Promise((resolve, reject) => {
        sensitiveImport(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default data
